package com.dewod.producesales.utils.request;

import android.os.Build;

import com.blankj.utilcode.util.ObjectUtils;

public enum ApiEnums {

    REGISTER("/register/{code}","get"),

    VALIDATE_ORDER_NO("/validateOrderNo?machineNo={code}", "get"),

    SUBMIT_SN("/submitForm?machineNo={code}", "get"),

    CANCEL_ONE("/cancelOne?machineNo={code}","get"),

    CANCEL("/cancel?machineNo={code}","get"),


    ENABLE_ORDER("/getEnableOrder?machineNo={code}","get"),

    UPDATE_ORDER("/updateRemark?machineNo={code}","get"),


    PDD_VALIDATE_ORDER_NO("/pdd/validateOrderNo?machineNo={code}","get"),

    PDD_CANCEL("/pdd/cancel?machineNo={code}","get"),

    PDD_CANCEL_ONE("/pdd/cancelOne?machineNo={code}","get"),

    PDD_SUBMIT_SN("/pdd/submitForm?machineNo={code}","get"),
    ;


    /**
     * 请求地址后缀
     */
    private final String urlSuffix;
    /**
     * 请求方式
     */
    private final String method;

    public final String serialNo = getSerialNo();

    ApiEnums(String urlSuffix, String method) {
        this.urlSuffix = urlSuffix.replace("{code}",serialNo);
        this.method = method;
    }

    public String getUrlSuffix() {
        return urlSuffix;
    }

    public String getMethod() {
        return method;
    }

    public static String getSerialNo(){
        String serialNo = "";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (ObjectUtils.equals(Build.UNKNOWN,Build.getSerial())){
                serialNo = "UNKNOWN";
            }else{
                serialNo = Build.getSerial();
            }
        }else{
            serialNo = "UNKNOWN";
        }
         return serialNo;
    }

}
